package com.mofang.ticketing.base.serve.sysconfig.controller;

import com.mofang.ticketing.base.client.pojo.request.SysConfigGetReqDTO;
import com.mofang.ticketing.base.serve.sysconfig.service.ISysConfigService;
import com.mofang.ticketing.common.core.exception.BizException;
import com.mofang.ticketing.common.core.result.Result;
import com.mofang.ticketing.common.core.urls.base.SysConfigUrl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author LGC
 */
@Api(tags = "系统配置")
@RestController
public class SysConfigController {

    @Resource
    private ISysConfigService sysConfigService;


    @ApiOperation(value = "自定义Validate验证测试")
    @PostMapping("/api/test")
    public Result<Object> test(@Validated @RequestBody TestValidate dto) {
        return Result.success(dto);
    }


    /*********************************** rpc ****************************************/

    @ApiOperation(value = "获取系统配置")
    @PostMapping(SysConfigUrl.CONFIG_GET)
    public Result<String> configGet(@Validated @RequestBody SysConfigGetReqDTO dto) {
        return Result.success(sysConfigService.getConfigValueByKey(dto.getKey()));
    }

    @ApiOperation(value = "test")
    @PostMapping("/feigntest")
    public Result<String> feigntest(){
        return Result.success("65656555");
    }

}

